package cn.wolfcode.trip.admin.filter;

import cn.wolfcode.trip.base.util.UploadUtil;
import org.apache.commons.io.FileUtils;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;

public class Imagefilter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response,
                         FilterChain chain) throws IOException, ServletException {

       //强转
        HttpServletRequest req= (HttpServletRequest) request;
        //获取图片地址
        String uri = req.getRequestURI();
        //获取完整的图片路径
        String imgUri = UploadUtil.ALIYUN_PAth + uri;
        //请求重定向
        HttpServletResponse resp = (HttpServletResponse) response;
        //放行
        resp.sendRedirect(imgUri);
    }


    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }



    @Override
    public void destroy() {

    }
}
